// transactional.decorator.ts
// 事务处理
export function Transactional(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
    const originalMethod = descriptor.value;
    descriptor.value = async function (...args: any[]) {
        const instance = this;
        try {
            await instance.beginTransaction();
            const result = await originalMethod.apply(instance, args);
            await instance.commitTransaction();
            return result;
        } catch (error) {
			console.log(error);
            await instance.rollbackTransaction();
            throw error;
        }
    };
    return descriptor;
}